home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / oji / nsISecureEnv.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  14KB  |  363 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsISecureEnv_h___
  39. #define nsISecureEnv_h___
  40.  
  41. #include "nsISupports.h"
  42. #include "nsIFactory.h"
  43. #include "nsISecurityContext.h"
  44. #include "jni.h"
  45.  
  46. enum jni_type 
  47. {
  48.     jobject_type = 0,
  49.     jboolean_type,
  50.     jbyte_type,
  51.     jchar_type,
  52.     jshort_type,
  53.     jint_type,
  54.     jlong_type,
  55.     jfloat_type,
  56.     jdouble_type,
  57.     jvoid_type
  58. };
  59.  
  60. class nsISecureEnv : public nsISupports {
  61. public:
  62.  
  63.     /**
  64.      * Create new Java object in LiveConnect.
  65.      *
  66.      * @param clazz      -- Java Class object.
  67.      * @param methodID   -- Method id
  68.      * @param args       -- arguments for invoking the constructor.
  69.      * @param result     -- return new Java object.
  70.      * @param ctx        -- security context 
  71.      */
  72.     NS_IMETHOD NewObject(/*[in]*/  jclass clazz, 
  73.                          /*[in]*/  jmethodID methodID,
  74.                          /*[in]*/  jvalue *args, 
  75.                          /*[out]*/ jobject* result,
  76.                          /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
  77.    
  78.     /**
  79.      * Invoke method on Java object in LiveConnect.
  80.      *
  81.      * @param type       -- Return type
  82.      * @param obj        -- Java object.
  83.      * @param methodID   -- method id
  84.      * @param args       -- arguments for invoking the constructor.
  85.      * @param result     -- return result of invocation.
  86.      * @param ctx        -- security context 
  87.      */
  88.     NS_IMETHOD CallMethod(/*[in]*/  jni_type type,
  89.                           /*[in]*/  jobject obj, 
  90.                           /*[in]*/  jmethodID methodID,
  91.                           /*[in]*/  jvalue *args, 
  92.                           /*[out]*/ jvalue* result,
  93.                           /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
  94.  
  95.     /**
  96.      * Invoke non-virtual method on Java object in LiveConnect.
  97.      *
  98.      * @param type       -- Return type
  99.      * @param obj        -- Java object.
  100.      * @param clazz      -- Class object
  101.      * @param methodID   -- method id
  102.      * @param args       -- arguments for invoking the constructor.
  103.      * @param ctx        -- security context 
  104.      * @param result     -- return result of invocation.
  105.      */
  106.     NS_IMETHOD CallNonvirtualMethod(/*[in]*/  jni_type type,
  107.                                     /*[in]*/  jobject obj, 
  108.                                     /*[in]*/  jclass clazz,
  109.                                     /*[in]*/  jmethodID methodID,
  110.                                     /*[in]*/  jvalue *args, 
  111.                                     /*[out]*/ jvalue* result,
  112.                                     /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
  113.  
  114.     /**
  115.      * Get a field on Java object in LiveConnect.
  116.      *
  117.      * @param type       -- Return type
  118.      * @param obj        -- Java object.
  119.      * @param fieldID    -- field id
  120.      * @param result     -- return field value
  121.      * @param ctx        -- security context 
  122.      */
  123.     NS_IMETHOD GetField(/*[in]*/  jni_type type,
  124.                         /*[in]*/  jobject obj, 
  125.                         /*[in]*/  jfieldID fieldID,
  126.                         /*[out]*/ jvalue* result,
  127.                         /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
  128.  
  129.     /**
  130.      * Set a field on Java object in LiveConnect.
  131.      *
  132.      * @param type       -- Return type
  133.      * @param obj        -- Java object.
  134.      * @param fieldID    -- field id
  135.      * @param val        -- field value to set
  136.      * @param ctx        -- security context 
  137.      */
  138.     NS_IMETHOD SetField(/*[in]*/ jni_type type,
  139.                         /*[in]*/ jobject obj, 
  140.                         /*[in]*/ jfieldID fieldID,
  141.                         /*[in]*/ jvalue val,
  142.                         /*[in]*/ nsISecurityContext* ctx = NULL) = 0;
  143.  
  144.     /**
  145.      * Invoke static method on Java object in LiveConnect.
  146.      *
  147.      * @param type       -- Return type
  148.      * @param clazz      -- Class object.
  149.      * @param methodID   -- method id
  150.      * @param args       -- arguments for invoking the constructor.
  151.      * @param result     -- return result of invocation.
  152.      * @param ctx        -- security context 
  153.      */
  154.     NS_IMETHOD CallStaticMethod(/*[in]*/  jni_type type,
  155.                                 /*[in]*/  jclass clazz,
  156.                                 /*[in]*/  jmethodID methodID,
  157.                                 /*[in]*/  jvalue *args, 
  158.                                 /*[out]*/ jvalue* result,
  159.                                 /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
  160.  
  161.     /**
  162.      * Get a static field on Java object in LiveConnect.
  163.      *
  164.      * @param type       -- Return type
  165.      * @param clazz      -- Class object.
  166.      * @param fieldID    -- field id
  167.      * @param result     -- return field value
  168.      * @param ctx        -- security context 
  169.      */
  170.     NS_IMETHOD GetStaticField(/*[in]*/  jni_type type,
  171.                               /*[in]*/  jclass clazz, 
  172.                               /*[in]*/  jfieldID fieldID, 
  173.                               /*[out]*/ jvalue* result,
  174.                               /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
  175.  
  176.  
  177.     /**
  178.      * Set a static field on Java object in LiveConnect.
  179.      *
  180.      * @param type       -- Return type
  181.      * @param clazz      -- Class object.
  182.      * @param fieldID    -- field id
  183.      * @param val        -- field value to set
  184.      * @param ctx        -- security context 
  185.      */
  186.     NS_IMETHOD SetStaticField(/*[in]*/ jni_type type,
  187.                               /*[in]*/ jclass clazz, 
  188.                               /*[in]*/ jfieldID fieldID,
  189.                               /*[in]*/ jvalue val,
  190.                               /*[in]*/ nsISecurityContext* ctx = NULL) = 0;
  191.  
  192.  
  193.     NS_IMETHOD GetVersion(/*[out]*/ jint* version) = 0;
  194.  
  195.     NS_IMETHOD DefineClass(/*[in]*/  const char* name,
  196.                            /*[in]*/  jobject loader,
  197.                            /*[in]*/  const jbyte *buf,
  198.                            /*[in]*/  jsize len,
  199.                            /*[out]*/ jclass* clazz) = 0;
  200.  
  201.     NS_IMETHOD FindClass(/*[in]*/  const char* name, 
  202.                          /*[out]*/ jclass* clazz) = 0;
  203.  
  204.     NS_IMETHOD GetSuperclass(/*[in]*/  jclass sub,
  205.                              /*[out]*/ jclass* super) = 0;
  206.  
  207.     NS_IMETHOD IsAssignableFrom(/*[in]*/  jclass sub,
  208.                                 /*[in]*/  jclass super,
  209.                                 /*[out]*/ jboolean* result) = 0;
  210.  
  211.     NS_IMETHOD Throw(/*[in]*/  jthrowable obj,
  212.                      /*[out]*/ jint* result) = 0;
  213.  
  214.     NS_IMETHOD ThrowNew(/*[in]*/  jclass clazz,
  215.                         /*[in]*/  const char *msg,
  216.                         /*[out]*/ jint* result) = 0;
  217.  
  218.     NS_IMETHOD ExceptionOccurred(/*[out]*/ jthrowable* result) = 0;
  219.  
  220.     NS_IMETHOD ExceptionDescribe(void) = 0;
  221.  
  222.     NS_IMETHOD ExceptionClear(void) = 0;
  223.  
  224.     NS_IMETHOD FatalError(/*[in]*/ const char* msg) = 0;
  225.  
  226.     NS_IMETHOD NewGlobalRef(/*[in]*/  jobject lobj, 
  227.                             /*[out]*/ jobject* result) = 0;
  228.  
  229.     NS_IMETHOD DeleteGlobalRef(/*[in]*/ jobject gref) = 0;
  230.  
  231.     NS_IMETHOD DeleteLocalRef(/*[in]*/ jobject obj) = 0;
  232.  
  233.     NS_IMETHOD IsSameObject(/*[in]*/  jobject obj1,
  234.                             /*[in]*/  jobject obj2,
  235.                             /*[out]*/ jboolean* result) = 0;
  236.  
  237.     NS_IMETHOD AllocObject(/*[in]*/  jclass clazz,
  238.                            /*[out]*/ jobject* result) = 0;
  239.  
  240.     NS_IMETHOD GetObjectClass(/*[in]*/  jobject obj,
  241.                               /*[out]*/ jclass* result) = 0;
  242.  
  243.     NS_IMETHOD IsInstanceOf(/*[in]*/  jobject obj,
  244.                             /*[in]*/  jclass clazz,
  245.                             /*[out]*/ jboolean* result) = 0;
  246.  
  247.     NS_IMETHOD GetMethodID(/*[in]*/  jclass clazz, 
  248.                            /*[in]*/  const char* name,
  249.                            /*[in]*/  const char* sig,
  250.                            /*[out]*/ jmethodID* id) = 0;
  251.  
  252.     NS_IMETHOD GetFieldID(/*[in]*/  jclass clazz, 
  253.                           /*[in]*/  const char* name,
  254.                           /*[in]*/  const char* sig,
  255.                           /*[out]*/ jfieldID* id) = 0;
  256.  
  257.     NS_IMETHOD GetStaticMethodID(/*[in]*/  jclass clazz, 
  258.                                  /*[in]*/  const char* name,
  259.                                  /*[in]*/  const char* sig,
  260.                                  /*[out]*/ jmethodID* id) = 0;
  261.  
  262.     NS_IMETHOD GetStaticFieldID(/*[in]*/  jclass clazz, 
  263.                                 /*[in]*/  const char* name,
  264.                                 /*[in]*/  const char* sig,
  265.                                 /*[out]*/ jfieldID* id) = 0;
  266.  
  267.     NS_IMETHOD NewString(/*[in]*/  const jchar* unicode,
  268.                          /*[in]*/  jsize len,
  269.                          /*[out]*/ jstring* result) = 0;
  270.  
  271.     NS_IMETHOD GetStringLength(/*[in]*/  jstring str,
  272.                                /*[out]*/ jsize* result) = 0;
  273.     
  274.     NS_IMETHOD GetStringChars(/*[in]*/  jstring str,
  275.                               /*[in]*/  jboolean *isCopy,
  276.                               /*[out]*/ const jchar** result) = 0;
  277.  
  278.     NS_IMETHOD ReleaseStringChars(/*[in]*/  jstring str,
  279.                                   /*[in]*/  const jchar *chars) = 0;
  280.  
  281.     NS_IMETHOD NewStringUTF(/*[in]*/  const char *utf,
  282.                             /*[out]*/ jstring* result) = 0;
  283.  
  284.     NS_IMETHOD GetStringUTFLength(/*[in]*/  jstring str,
  285.                                   /*[out]*/ jsize* result) = 0;
  286.     
  287.     NS_IMETHOD GetStringUTFChars(/*[in]*/  jstring str,
  288.                                  /*[in]*/  jboolean *isCopy,
  289.                                  /*[out]*/ const char** result) = 0;
  290.  
  291.     NS_IMETHOD ReleaseStringUTFChars(/*[in]*/  jstring str,
  292.                                      /*[in]*/  const char *chars) = 0;
  293.  
  294.     NS_IMETHOD GetArrayLength(/*[in]*/  jarray array,
  295.                               /*[out]*/ jsize* result) = 0;
  296.  
  297.     NS_IMETHOD NewObjectArray(/*[in]*/  jsize len,
  298.                         /*[in]*/  jclass clazz,
  299.                         /*[in]*/  jobject init,
  300.                         /*[out]*/ jobjectArray* result) = 0;
  301.  
  302.     NS_IMETHOD GetObjectArrayElement(/*[in]*/  jobjectArray array,
  303.                                      /*[in]*/  jsize index,
  304.                                      /*[out]*/ jobject* result) = 0;
  305.  
  306.     NS_IMETHOD SetObjectArrayElement(/*[in]*/  jobjectArray array,
  307.                                      /*[in]*/  jsize index,
  308.                                      /*[in]*/  jobject val) = 0;
  309.  
  310.     NS_IMETHOD NewArray(/*[in]*/ jni_type element_type,
  311.                         /*[in]*/  jsize len,
  312.                         /*[out]*/ jarray* result) = 0;
  313.  
  314.     NS_IMETHOD GetArrayElements(/*[in]*/  jni_type type,
  315.                                 /*[in]*/  jarray array,
  316.                                 /*[in]*/  jboolean *isCopy,
  317.                                 /*[out]*/ void* result) = 0;
  318.  
  319.     NS_IMETHOD ReleaseArrayElements(/*[in]*/ jni_type type,
  320.                                     /*[in]*/ jarray array,
  321.                                     /*[in]*/ void *elems,
  322.                                     /*[in]*/ jint mode) = 0;
  323.  
  324.     NS_IMETHOD GetArrayRegion(/*[in]*/  jni_type type,
  325.                               /*[in]*/  jarray array,
  326.                               /*[in]*/  jsize start,
  327.                               /*[in]*/  jsize len,
  328.                               /*[out]*/ void* buf) = 0;
  329.  
  330.     NS_IMETHOD SetArrayRegion(/*[in]*/  jni_type type,
  331.                               /*[in]*/  jarray array,
  332.                               /*[in]*/  jsize start,
  333.                               /*[in]*/  jsize len,
  334.                               /*[in]*/  void* buf) = 0;
  335.  
  336.     NS_IMETHOD RegisterNatives(/*[in]*/  jclass clazz,
  337.                                /*[in]*/  const JNINativeMethod *methods,
  338.                                /*[in]*/  jint nMethods,
  339.                                /*[out]*/ jint* result) = 0;
  340.  
  341.     NS_IMETHOD UnregisterNatives(/*[in]*/  jclass clazz,
  342.                                  /*[out]*/ jint* result) = 0;
  343.  
  344.     NS_IMETHOD MonitorEnter(/*[in]*/  jobject obj,
  345.                             /*[out]*/ jint* result) = 0;
  346.  
  347.     NS_IMETHOD MonitorExit(/*[in]*/  jobject obj,
  348.                            /*[out]*/ jint* result) = 0;
  349.  
  350.     NS_IMETHOD GetJavaVM(/*[in]*/  JavaVM **vm,
  351.                          /*[out]*/ jint* result) = 0;
  352. };
  353.  
  354. #define NS_ISECUREENV_IID                               \
  355. {   /* ca9148d0-598a-11d2-a1d4-00805f8f694d */          \
  356.     0xca9148d0,                                         \
  357.     0x598a,                                             \
  358.     0x11d2,                                             \
  359.     {0xa1, 0xd4, 0x00, 0x80, 0x5f, 0x8f, 0x69, 0x4d }   \
  360. }
  361.  
  362. #endif // nsISecureEnv_h___
  363.